package com.ellricky.excute_president.ui.activity.home.leave

import android.view.View
import android.widget.AdapterView
import com.andr.common.http.callback.BaseCallback
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.mvp.BasePresenter
import com.ellricky.baselib.http.callback.EListCallback
import com.ellricky.baselib.ui.base.BaseRefreshActivity
import com.ellricky.excute_president.*

class LeaveApplyListActivity : BaseRefreshActivity<Void, BasePresenter<Void>, PdLeaveEntity>() {

    override fun initUIView() {
        super.initUIView()
        mTvTitle.setText(R.string.pd_leave_apply)
    }

    override fun getResponseCallback(): BaseCallback {
        return object : EListCallback<PdLeaveEntity>(this) {
            override fun onSuccess(data: MutableList<PdLeaveEntity>?, msg: String?) {
                dataSource = data
                rvView.onLoadFinish(dataSource, refresh)
            }

            override fun onErrorCode(code: String?, msg: String?) {
                super.onErrorCode(code, msg)
                rvView.onRefreshFailed(refresh)
            }

            override fun onHttpError(code: String?, msg: String?) {
                super.onHttpError(code, msg)
                rvView.onRefreshFailed(refresh)
            }
        }
    }

    override fun getRvAdapter(): BaseRecyclerAdapter<PdLeaveEntity> {
        return PdLeaveApplyAdapter(this)
    }


    override fun getUrlPath(): String {
        return API_LEAVE_LIST
    }

    override fun onItemClick(adapterView: AdapterView<*>?, view: View?, i: Int, l: Long) {
        super.onItemClick(adapterView, view, i, l)
        val entity = adapter[i]
        jumpLeaveApplyDetail(this, entity.id, entity.approveStatus)
    }


}